import pygame.font

class Button():

    def __init__(self, ai_settings, screen, play_msg, exit_msg, replay_msg):

        self.screen = screen
        self.screen_rect = screen.get_rect()

        self.width, self.height = 200, 50
        self.button_color = (0, 255, 0)
        self.text_color = (255, 255, 255)
        self.font = pygame.font.SysFont(None, 48)

        self.play_rect = pygame.Rect(0, 0, self.width, self.height)
        self.play_rect.center = self.screen_rect.center

        self.exit_rect = pygame.Rect(0, 0, self.width, self.height)
        self.exit_rect.center = self.screen_rect.center
        self.exit_rect.top = self.play_rect.top - 30

        self.replay_rect = pygame.Rect(0, 0, self.width, self.height)
        self.replay_rect.center = self.screen_rect.center
        self.replay_rect.top = self.play_rect.top + 30

        self.prep_msg(play_msg)
        self.exit_msg(exit_msg)
        self.replay_msg(replay_msg)


    def prep_msg(self, msg):

        self.msg_image = self.font.render(msg, True, self.text_color, self.button_color)
        self.msg_image_rect = self.msg_image.get_rect()
        self.msg_image_rect.center = self.play_rect.center


    def exit_msg(self, msg):

        self.msg_image_1 = self.font.render(msg, True, self.text_color, self.button_color)
        self.msg_image_rect_1 = self.msg_image_1.get_rect()
        self.msg_image_rect_1.center = self.exit_rect.center


    def replay_msg(self, msg):
        self.msg_image_2 = self.font.render(msg, True, self.text_color, self.button_color)
        self.msg_image_rect_2 = self.msg_image_2.get_rect()
        self.msg_image_rect_2.center = self.replay_rect.center


    def draw_play_button(self):

        self.screen.fill(self.button_color, self.play_rect)
        self.screen.blit(self.msg_image, self.msg_image_rect)


    def draw_exit_button(self):
        self.screen.fill(self.button_color, self.exit_rect)
        self.screen.blit(self.msg_image_1, self.msg_image_rect_1)


    def draw_replay_button(self):
        self.screen.fill(self.button_color, self.replay_rect)
        self.screen.blit(self.msg_image_2, self.msg_image_rect_2)